public class Test {
    // 两种方式都会出现超卖的现象
    // 当 ticket = 1 或 2 时，三个线程拿到手的都是1 或 2，同时sleep。就会导致超卖。
    public static void main1(String[] args) {
        SellTicket1 s1 = new SellTicket1();
        SellTicket1 s2 = new SellTicket1();
        SellTicket1 s3 = new SellTicket1();
        s1.start();
        s2.start();
        s3.start();
    }

    public static void main(String[] args) {
        SellTicket2 s1 = new SellTicket2();
        new Thread(s1).start();
        new Thread(s1).start();
        new Thread(s1).start();
    }
}
